package com.info3k.client.components;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.info3k.client.Info3K;

public class GlassDialogBox extends DialogBox {

	private HTML glass = new HTML();
	
	public VerticalPanel panel = new VerticalPanel();
	
	public FlowPanel content = new FlowPanel();
	
	public Button closeButton = new Button(Info3K.msgs.close());
	
	public FlowPanel footer = new FlowPanel();
	
	@Override
	public void center() {
		RootPanel.get().add(glass);
		super.center();
	}
	
	@Override
	public void hide() {
		RootPanel.get().remove(glass);
		super.hide();
	}
	
	public GlassDialogBox(){
		setWidget(panel);
		setAnimationEnabled(true);
		glass.getElement().setId("glass");
		glass.setStylePrimaryName("rxf-glass");
		content.setWidth("100%");
		content.setHeight("100%");
		footer.getElement().getStyle().setProperty("margin", "10px 0 0 0");
		panel.add(content);	
		panel.add(footer);
		panel.setCellHeight(content, "90%");
		panel.setCellHeight(footer, "10%");
		panel.setCellHorizontalAlignment(footer, HorizontalPanel.ALIGN_RIGHT);
		
		closeButton.addClickHandler(new ClickHandler(){
			public void onClick(ClickEvent event) {
				hide();
			}
		});
	}
	
	public HTML getGlass() {
		return glass;
	}
	
	public void setGlass(HTML glass) {
		this.glass = glass;
	}
}
